{% extends "base.html" %}

{% load i18n translations %}

{% block breadcrumbs %}
  <li class="breadcrumb-item">
    <a href="{% url 'manage' %}">{% translate "Manage" %}</a>
  </li>
  <li class="breadcrumb-item">
    <a href="{% url 'manage-alerts' %}">{% translate "Component alerts" %}</a>
  </li>
{% endblock breadcrumbs %}

{% block content %}
  {% regroup alerts by name as alert_list %}
  {% for dummy, items in alert_list %}
    <div class="card">
      <div class="card-header">
        <h4 class="card-title">{{ items.0.obj.verbose }}</h4>
      </div>
      <div class="card-body">
        <p>
          {% for alert in items %}
            <a href="{{ alert.component.get_absolute_url }}?alerts=1#alerts"
               class="btn btn-link">
              {{ alert.component }}
              {% if alert.dismissed %}
                <span class="badge">{% translate "dismissed" %}</span>
              {% endif %}
            </a>
          {% endfor %}
        </p>
      </div>
    </div>
  {% endfor %}

  {% if no_components %}
    <div class="card">
      <div class="card-header">
        <h4 class="card-title">{% translate "Projects without components" %}</h4>
      </div>
      <div class="card-body">
        <p>
          {% for project in no_components %}
            <a href="{{ project.get_absolute_url }}" class="btn btn-link">{{ project }}</a>
          {% endfor %}
        </p>
      </div>
    </div>
  {% endif %}

  {% if not alerts and not no_components %}
    {% translate "Congratulations, your setup seems to work." as msg %}
    {% show_message "success" msg %}
  {% endif %}
{% endblock content %}
